<script>
export default {
  name: "Register",
  data() {
    return {
      user: {},
    }
  },
  methods: {
    Register() {
      this.request.post("http://localhost:9090/user/register", this.user).then(res => {
        if(res.code !== "200") {
          this.$message.error(res.msg)
        } else {
          this.$router.push("/login")
          this.$message.success("注册成功！")
        }
      })
    }
  }
}
</script>

<template>
  <div class="wrapper">
    <div style="opacity: 0.9; margin: 100px auto; background-color: #fff; width: 350px; height: 530px; padding: 20px; border-radius: 10px">
      <div style="margin: 20px 0; text-align: center; font-size: 24px"><b>注 册</b></div>
      <el-input placeholder="用户名" size="medium" style="margin: 10px 0" prefix-icon="el-icon-user" v-model="user.username"></el-input>
      <el-input placeholder="密码" size="medium" style="margin: 10px 0" prefix-icon="el-icon-lock" show-password v-model="user.password"></el-input>
      <el-input placeholder="昵称" size="medium" style="margin: 10px 0" prefix-icon="el-icon-user-solid" v-model="user.nickname"></el-input>
      <el-input placeholder="邮箱" size="medium" style="margin: 10px 0" prefix-icon="el-icon-message" v-model="user.email"></el-input>
      <el-input placeholder="手机号" size="medium" style="margin: 10px 0" prefix-icon="el-icon-phone-outline" v-model="user.phone"></el-input>
      <el-input placeholder="地址" size="medium" style="margin: 10px 0" prefix-icon="el-icon-position" v-model="user.address"></el-input>
      <div style="margin: 10px 0; text-align: right">
        <el-button type="primary" size="small" autocomplete="off" @click="Register">确定</el-button>
        <el-button type="warning" size="small" autocomplete="off" @click="$router.push('/login')">取消</el-button>
      </div>
    </div>
  </div>
</template>

<style>
  .wrapper {
    height: 100vh;
    //background-image: linear-gradient(to bottom right, #FC466B, #3F5EFB);
    background-image: url("../../public/Only_Rick.png");
    background-size: 100%, 100%;
    overflow: hidden;
  }
</style>